
@import 'config'

/*
 * Alias "nowrap" as "no-wrap".
 */

no-wrap = unquote('nowrap')

/*
 * Vendor support for the given prop / arguments,
 * optionally specifying the only prefixes to utilize,
 * or those which should be ignored.
 */

vendor(prop, args, only = null, ignore = null)
  for prefix in vendor-prefixes
    unless (only and !(prefix in only)) or (ignore and prefix in ignore)
      if official == prefix
        {prop}: args
      else
        {'-' + prefix + '-' + prop}: args

/*
 * Vendor "box-shadow" support.
 */

box-shadow()
  vendor('box-shadow', arguments)

/*
 * Vendor "user-size" support.
 */

user-select()
  vendor('user-select', arguments)

/*
 * Vendor "column-count" support.
 */

column-count()
  vendor('column-count', arguments)

/*
 * Vendor "column-gap" support.
 */

column-gap()
  vendor('column-gap', arguments)

/*
 * Vendor "column-rule" support.
 */

column-rule()
  vendor('column-rule', arguments)

/*
 * Vendor "column-rule-color" support.
 */

column-rule-color()
  vendor('column-rule-color', arguments)

/*
 * Vendor "column-rule-width" support.
 */

column-rule-width()
  vendor('column-rule-width', arguments)

/*
 * Vendor "column-rule-style" support.
 */

column-rule-style()
  vendor('column-rule-style', arguments)

/*
 * Vendor "column-width" support.
 */

column-width()
  vendor('column-width', arguments)

/*
 * Vendor "background-size" support.
 */

background-size()
  vendor('background-size', arguments)

/*
 * Vendor "transform" support.
 */

transform()
  vendor('transform', arguments)

/*
 * Vendor "border-image" support.
 */

border-image()
  vendor('border-image', arguments)

/*
 * Vendor "transition" support.
 */

transition()
  vendor('transition', arguments)

/*
 * Vendor "transition-property" support.
 */

transition-property()
  vendor('transition-property', arguments)

/*
 * Vendor "transition-duration" support.
 */

transition-duration()
  vendor('transition-duration', arguments)

/*
 * Vendor "transition-timing-function" support.
 */

transition-timing-function()
  vendor('transition-timing-function', arguments)

/*
 * Vendor "transition-delay" support.
 */

transition-delay()
  vendor('transition-delay', arguments)

/*
 * Vendor "backface-visibility" support.
 */

backface-visibility()
  vendor('backface-visibility', arguments)


/*
 * Opacity with conditional IE support.
 */

opacity(n)
  opacity: n
  if support-for-ie
    filter: 'progid:DXImageTransform.Microsoft.Alpha(Opacity=%s)' % round(n * 100)

/*
 * Alias the "white-space" property.
 */

whitespace()
  white-space: arguments

/*
 * Vendor "box-sizing" support.
 */

box-sizing()
  vendor('box-sizing', arguments)

/*
 * Vendor "box-orient" support.
 */

box-orient()
  vendor('box-orient', arguments)

/*
 * Vendor "box-flex" support.
 */

box-flex()
  vendor('box-flex', arguments)

/*
 * Vendor "box-flex-group" support.
 */

box-flex-group()
  vendor('box-flex-group', arguments)

/*
 * Vendor "box-align" support.
 */

box-align()
  vendor('box-align', arguments)

/*
 * Vendor "box-pack" support.
 */

box-pack()
  vendor('box-pack', arguments)

/*
 * Vendor "box-direction" support.
 */

box-direction()
  vendor('box-direction', arguments)

/*
 * Vendor "animation" support.
 */

animation()
  vendor('animation', arguments)


/*
 * Vendor "animation-name" support.
 */

animation-name()
  vendor('animation-name', arguments)

/*
 * Vendor "animation-duration" support.
 */

animation-duration()
  vendor('animation-duration', arguments)

/*
 * Vendor "animation-delay" support.
 */

animation-delay()
  vendor('animation-delay', arguments)

/*
 * Vendor "animation-direction" support.
 */

animation-direction()
  vendor('animation-direction', arguments)

/*
 * Vendor "animation-iteration-count" support.
 */

animation-iteration-count()
  vendor('animation-iteration-count', arguments)

/*
 * Vendor "animation-timing-function" support.
 */

animation-timing-function()
  vendor('animation-timing-function', arguments)

/*
 * Vendor "animation-play-state" support.
 */

animation-play-state()
  vendor('animation-play-state', arguments)

/*
 * Vendor "animation-fill-mode" support.
 */

animation-fill-mode()
  vendor('animation-fill-mode', arguments)

/*
 * Vendor "border-image" support.
 */

border-image()
  vendor('border-image', arguments)

/*
 * Vendor "hyphens" support.
 */

hyphens()
  vendor('hyphens', arguments)


/*
 * Vendor "appearance" support.
 */

appearance()
  vendor('appearance', arguments)

/*
 * Helper for border-radius().
 */

-apply-border-radius(pos)
  if length(pos) == 3
    // border-radius: <top | buttom> <left | right> <n>
    y = pos[0]
    x = pos[1]
    vendor('border-radius-%s%s' % pos, pos[2], only: moz)
    vendor('border-%s-%s-radius' % pos, pos[2], ignore: moz)
  else if pos[0] in (top bottom)
    // border-radius: <top | bottom> <n>
    -apply-border-radius(pos[0] left pos[1])
    -apply-border-radius(pos[0] right pos[1])
  else if pos[0] in (left right)
    // border-radius: <left | right> <n>
    unshift(pos, top);
    -apply-border-radius(pos)
    pos[0] = bottom
    -apply-border-radius(pos)

/*
 * border-radius supporting vendor prefixes and
 * augmented behavior.
 *
 * Examples:
 *
 *    border-radius: 2px 5px
 *    border-radius: top 5px bottom 10px
 *    border-radius: left 5px
 *    border-radius: top left 5px
 *    border-radius: top left 10px bottom right 5px
 *    border-radius: top left 10px, bottom right 5px
 *
 */

border-radius()
  pos = ()
  augmented = false
  for args in arguments
    for arg in args
      if arg is a 'ident'
        append(pos, arg)
        augmented = true
      else
        append(pos, arg)
        if augmented
          -apply-border-radius(pos)
          pos = ()
  vendor('border-radius', pos) unless augmented

